const {
  $util,
} = getApp();
Page({
  data: {
    list: [],
    hasMore: true,
    page: 1,
  },
  onLoad(ops) {
    this.loadList();
    wx.setNavigationBarTitle({
      title: '红歌精选',
    });
  },
  loadList() {
    let {
      page,
      list,
    } = this.data;
    $util.request({
      url: 'entry/wxapp/edu.partymusic.getPartyList',
      data: {
        page: page,
      },
      success: (res) => {
        let nList = res.list;
        if (page > 1) {
          nList = [...list, ...nList];
        }
        this.setData({
          list: nList,
          hasMore: res.list.length > 0,
          page: res.list.length > 0 ? page + 1 : page,
        });
      },
    });
  },
  onReachBottom() {
    this.data.hasMore && this.loadList();
  },
  onShareAppMessage() {
    return {
      title: '红歌精选',
    };
  },
});